package com.sqlcheck.dto.response;

import lombok.Builder;
import lombok.Data;

import java.util.List;
import java.util.Map;

@Data
@Builder
public class DashboardStatisticsVO {
    
    // 任务统计
    private TaskStatistics taskStatistics;
    
    // SQL语句统计
    private SqlStatementStatistics sqlStatementStatistics;
    
    // 兼容性问题统计
    private IssueStatistics issueStatistics;
    
    // 规则统计
    private RuleStatistics ruleStatistics;
    
    // 最近任务列表
    private List<RecentTaskVO> recentTasks;
    
    // 系统状态
    private SystemStatus systemStatus;
    
    @Data
    @Builder
    public static class TaskStatistics {
        private Long totalTasks;
        private Long completedTasks;
        private Long runningTasks;
        private Long failedTasks;
        private Long pendingTasks;
    }
    
    @Data
    @Builder
    public static class SqlStatementStatistics {
        private Long totalStatements;
        private Map<String, Long> statementsByType; // QUERY, DML, DDL等
        private Map<String, Long> statementsBySource; // MYBATIS_XML, JPA_ANNOTATION等
        private Long ddlStatements;
        private Long queryStatements;
        private Long dmlStatements;
    }
    
    @Data
    @Builder
    public static class IssueStatistics {
        private Long totalIssues;
        private Long highSeverityIssues;
        private Long mediumSeverityIssues;
        private Long lowSeverityIssues;
        private Long infoIssues;
        private Map<String, Long> issuesByCategory;
    }
    
    @Data
    @Builder
    public static class RuleStatistics {
        private Long totalRules;
        private Long activeRules;
        private Long inactiveRules;
        private Map<String, Long> rulesByCategory;
        private Map<String, Long> rulesBySeverity;
    }
    
    @Data
    @Builder
    public static class RecentTaskVO {
        private Long id;
        private String taskName;
        private String taskType;
        private String status;
        private Integer progress;
        private String createdAt;
        private String updatedAt;
        private Long sqlStatementCount;
        private Long issueCount;
    }
    
    @Data
    @Builder
    public static class SystemStatus {
        private String serviceStatus;
        private String serviceVersion;
        private String databaseStatus;
        private String lastUpdateTime;
        private Boolean healthCheckStatus;
    }
}